#!/usr/bin/env python

import sys

F_SAMPLE = 1000.0
MAX_PULSE = 120.0
PEAK_RADIUS = 2
MIN_BEAT = 50.0
MAX_BEAT = 130.0

def data_gen ():
    line = sys.stdin.readline()
    current_x = 0
    while line:
        try:
            val = int(line)
            yield current_x, val
        except:
            pass
        line = sys.stdin.readline()
        current_x += 1

def increasingp (data):
    for i in range(len(data)-1):
        if data[i][1] > data[i+1][1]:
            return False
    return True

def decreasingp (data):
    for i in range(len(data)-1):
        if data[i][1] < data[i+1][1]:
            return False
    return True

def bitonicp (data, concave_down):
    assert len(data) % 2 == 1
    midrange = (len(data) - 1)/2
    if concave_down:
        dec = data[0:midrange+1]
        inc = data[midrange:]
    else:
        inc = data[0:midrange+1]
        dec = data[midrange:]

    if increasingp(inc) and decreasingp(dec):
        return True
    return False

def emit_range (start, end):
    len_x = end[0] - start[0] + 1
    for x in range(len_x):
        y = start[1] + (1.0 * x) / len_x * (end[1] - start[1])
        print int(round(y))

def peak_gen (data_gen, radius):
    interval = 2 * radius + 1
    seeking_positive = True
    candidates = []
    buf = []

    while len(buf) < interval - 1:
        emts = data_gen.next()
        buf.append(emts)
        if len(buf) == 1:
            yield(emts)

    for emts in data_gen:
        buf.append(emts)
        if bitonicp(buf, seeking_positive):
            candidates.append(buf[len(buf)/2])
            seeking_positive = not seeking_positive
        if len(candidates) >= 2:
            yield candidates[0]
            del candidates[0]
        del buf[0]


def smooth_peak_gen ():
    global PEAK_RADIUS
    Max_Error = 1
    held = []
    for emt in peak_gen(data_gen(), PEAK_RADIUS):
        assert len(held) <= 3

        if len(held) == 0:
            held.append(emt)
            continue

        if abs(held[0][1] - emt[1]) <= Max_Error:
            held.append(emt)
            if len(held) == 4:
                del held[1]
                del held[2]
        else:
            if len(held) > 1:
                nx = int(sum([v[0] for v in held])/len(held))
                ny = int(sum([v[1] for v in held])/len(held))
                held[0] = nx, ny
                del held[1:]
            while len(held) != 0:
                yield held[0]
                del held[0]
            held.append(emt)


MIN_DIST = int(F_SAMPLE * 60 / MAX_BEAT / 2)
MAX_DIST = int(F_SAMPLE * 60 / MIN_BEAT / 2)

def lt (a, b):
    return (a < b)
def gt (a, b):
    return (a > b)

def pulse_peak_gen ():
    global MIN_DIST
    global MAX_DIST

    gen = peak_gen(smooth_peak_gen(), 1)
    compare = gt
    inv_compare = lt

    current = gen.next() # en y: maximo si compare es gt, minimo si compare es lt
    next_series = [] # en y: inv_compare es verdadero de a pares

    range_min = current[0]
    range_max = range_min + MAX_DIST - MIN_DIST
    for emt in gen:
        if emt[0] < range_min:
            continue

        if current == None:
            current = emt

        if emt[0] > range_max:
            yield current
            range_min = current[0] + MIN_DIST
            range_max = current[0] + MAX_DIST

            if len(next_series) != 0:
                current = next_series[0]
                next_series = []
                compare, inv_compare = inv_compare, compare
            else:
                current = None
                next_series = []
                compare, inv_compare = inv_compare, compare
                continue

        if compare(emt[1], current[1]):
            current = emt
            while len(next_series) > 0 and next_series[0][0] <= current[0] + MIN_DIST:
                del next_series[0]
        elif current[0] + MIN_DIST <= emt[0]:
            next_series.append(emt)
            while len(next_series) >= 2 and not inv_compare(next_series[-2][1], next_series[-1][1]):
                del next_series[-2]

def main (show_tuples):
    gen = pulse_peak_gen()
    last_emt = gen.next()
    for emt in gen:
        if show_tuples:
            print emt
        else:
            emit_range(last_emt, emt)
            last_emt = emt
            
if __name__ == "__main__":
    main(len(sys.argv) == 1)

